package org.adorsys.aderp.jpa.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.adorsys.aderp.jpa.api.change.ChangeRecordPublisher;


public class RepositoryMap {

	private Map<Class<?>, AderpJPARepository> repositoryMap = new HashMap<Class<?>, AderpJPARepository>();
	private Map<Class<?>, BusinessKeyInfo> businessKeyInfoMap = new HashMap<Class<?>, BusinessKeyInfo>();
	private Map<Class<?>, ChangeRecordPublisher> publisherMap = new HashMap<Class<?>, ChangeRecordPublisher>();
	
	public <T, ID extends Serializable> void putRepository(Class<T> klass, AderpJPARepository<T, ID> jpaRepository){
		repositoryMap.put(klass, jpaRepository);
	}
	
	public <T, ID extends Serializable> AderpJPARepository<T, ID> getRepository(Class<T> klass){
		return repositoryMap.get(klass);
	}

	public <T, ID extends Serializable> void putBusinessKeyInfo(Class<T> klass, BusinessKeyInfo<T, ID> businessKeyInfo){
		businessKeyInfoMap.put(klass, businessKeyInfo);
	}
	
	public <T, ID extends Serializable> BusinessKeyInfo<T, ID> getBusinessKeyInfo(Class<T> klass){
		return businessKeyInfoMap.get(klass);
	}
	
	public void putPublisher(Class<?> entityKlass, ChangeRecordPublisher publisher){
		publisherMap.put(entityKlass, publisher);
	}
	
	public ChangeRecordPublisher getPublisher(Class<?> entityKlass){
		return publisherMap.get(entityKlass);
	}
}
